// vuex持久化插件
import createPersistedState from 'vuex-persistedstate'

import Vue from 'vue';
import Vuex from 'vuex';
import system from '@/store/modules/system.js';
import cars from '@/store/modules/cars.js';
import brand from '@/store/modules/brand.js'
import goods from '@/store/modules/goods.js'
import getters from './getters.js';

Vue.use(Vuex);

const store = new Vuex.Store({
	getters,
	modules: {
		system,
		cars,
		brand,
		goods,
	},
	plugins: [
		createPersistedState({
			paths: ['cars'],
			storage: {
				getItem: (key) => {
					return uni.getStorageSync(key)
				},
				setItem: (key, value) => {
					return uni.setStorageSync(key, value)
				},
				removeItem: (key) => {
					return uni.removeStorageSync(key)
				}
			}
		})
	]
})

export default store;